package com.example.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

public class zzzzz2025103101RecommendFragment extends Fragment {
    private View view;
    private String[] names1 = {"三荤五素一份米饭", "豪华双人套餐",
            "双人套餐（含两份米饭）"};
    private String[] sales1 = {"月售520 好评度80%", "月售184 好评度68%",
            "月售114 好评度60%"};
    private String[] prices1 = {"￥23", "￥41", "￥32"};
    private int[] imgs1 = {R.drawable.z2025103101_recom_one, R.drawable.z2025103101_recom_two,
            R.drawable.z2025103101_recom_three};
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.zzzzz2025103101frag_layout, container,false);
        ListView listView=view.findViewById(R.id.zzzzz2025103101lv_list);
        MyBaseAdapter adapter=new MyBaseAdapter();
        listView.setAdapter(adapter);
        return view;
    }
    class MyBaseAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return names1.length;
        }

        @Override
        public Object getItem(int i) {
            return names1[i];
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View converView, ViewGroup viewGroup) {
            View view=View.inflate(getActivity(),R.layout.zzzzz2025103101list_item,null);
            TextView tv_name=view.findViewById(R.id.zzzzz2025103101iv_name);
            TextView tv_sale=view.findViewById(R.id.zzzzz2025103101iv_sale);
            TextView tv_price=view.findViewById(R.id.zzzzz2025103101iv_price);
            ImageView iv=view.findViewById(R.id.zzzzz2025103101iv_img);

            tv_name.setText(names1[i]);
            tv_sale.setText(sales1[i]);
            tv_price.setText(prices1[i]);
            iv.setImageResource(imgs1[i]);
            return view;
        }
    }
}
